package org.xmh.demo.test;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class DefaultAction extends ActionSupport{

	private static final long serialVersionUID = -6544342288361497487L;
	private String pagePath;
	
	/* 如果找不到的Action都将请求到这里,尝试转请求为请求jsp页面
	 * (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception {
		//因此Action未经过struts2的默认拦截器,故只能如此获得HttpServletRequest
		HttpServletRequest request=ServletActionContext.getRequest();
		String servletPaht=request.getServletPath();
		System.out.println("Class:DefaultAction Mthod:execute 请求URL:"+request.getRequestURL().toString());
		this.setPagePath(servletPaht);
		return SUCCESS;
	}

	public String getPagePath() {
		return pagePath;
	}

	public void setPagePath(String pagePath) {
		this.pagePath = pagePath;
	}	
		
}
